<template>
  <div class="box">
    <div class="title">{{ title }}</div>
    <ul>
      <li
        v-for="menu in $store.getters.tree"
        :key="menu.id"
        :class="{active: $store.state.activeMenuId== menu.id }"
        @click="$store.commit('setActiveMenuId', menu.id)"
      >
        <span>{{ menu.name }}</span>
      </li>
      <li>
        <el-dropdown>
          <span class="el-dropdown-link">
            {{ $store.state.user.username }}
            <i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>修改</el-dropdown-item>
            <el-dropdown-item>退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "Header",
  data() {
    return {
      activeId: 0,
      /**
       * 标题
       */
      title: process.env.VUE_APP_TITLE,
    };
  },
};
</script>

<style lang="scss" scoped>
.box {
  height: 60px;
  width: 100%;
  background: rgb(84, 92, 100);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 0 20px;
  box-sizing: border-box;
  .title {
    font-size: 20px;
    font-weight: 500;
  }
  ul {
    list-style: none;
    overflow: hidden;
    li {
      float: left;
      padding: 0 20px;
      cursor: pointer;
      height: 60px;
      font-size: 14px;
      line-height: 60px;
      transition: 0.2s ease;
      box-sizing: border-box;

      &:hover {
        background: rgb(67, 74, 80);
      }
      &.active {
        color: rgb(255, 208, 75);
        border-bottom: 3px solid currentColor;
      }
      ::v-deep .el-dropdown {
        height: 100%;
        color: white;
      }
    }
  }
}
</style>